import MyEvent from "./eventClass";
const myEvent = new MyEvent();
class EventStore<T> {
  constructor(
    public eventName: string, //事件名称
    public eventParam?: T //事件参数
  ) {}

  emit = (eventParam?: T) => {
    myEvent.emit(this.eventName, eventParam);
  };

  on = (fn: (param: T) => any) => {
    myEvent.on(this.eventName, fn);
  };

  once = (fn: (param: T) => any) => {
    myEvent.once(this.eventName, fn);
  };

  off = (callback?) => {
    myEvent.off(this.eventName, callback);
  };
}

export default EventStore;
